//
//  CAEcgRecord.h
//  CareRingApp
//
//  Created by Linktop on 2024/4/7.
//

#import <Foundation/Foundation.h>
#import "CAEcgAlgorithmResults.h"

NS_ASSUME_NONNULL_BEGIN

extern const int ECG_MESURING_DURA_SECS_FOR_LOCAL;


// 本地结论类型
typedef NS_ENUM(NSUInteger, ECG_CONCLUSION) {
    CONCLUSION_SINUS_RHYTHM = 1 , // 窦性心律
    CONCLUSION_AFI ,               // 房颤
    CONCLUSION_HIGH_HR ,            // 高心率
    CONCLUSION_LOW_HR ,             // 低心率
    CONCLUSION_IN_CONCLUSIVE ,      // 不确定
    CONCLUSION_POOR_RECORDING ,     // 记录不佳
    CONCLUSION_NOT_ENOUGH_TIME ,    // 不足时间
};

// 网络存储诊断结果
typedef NS_ENUM(NSUInteger, NET_ECG_CONCLUSION) {
    
    NET_CONCLUSION_SINUS_RHYTHM = 1 , // 窦性心律
    NET_CONCLUSION_POOR_RECORDING = 2,     // 记录不佳
    NET_CONCLUSION_LOW_HR = 3,             // 低心率
    NET_CONCLUSION_AFI = 4,               // 房颤
    NET_CONCLUSION_HIGH_HR = 5,            // 高心率
    NET_CONCLUSION_IN_CONCLUSIVE = 6,      // 不确定
};


typedef NS_ENUM(NSUInteger, ECG_FREQ_TYPE) {
    ECG_FREQ_512 = 0, // 数据频率的 512/s
    ECG_FREQ_500 = 1,// 数据频率的 500/s
};


typedef NS_ENUM(NSInteger, ECG_WEAR_HAND) {
    LEFT_HAND = -1,
    RIGHT_HAND = 1,
};


@interface CAEcgRecord : NSObject

@property(strong, nonatomic) NSString *account; // 账号
@property(strong, nonatomic) NSNumber *startTs, *endTs; // 开始 结束时间

@property(strong, nonatomic) NSNumber *avgHeartRate; // 平均心率
@property(strong, nonatomic) NSString *dayFormatString; //日期格式化字符串

@property(strong, nonatomic) NSString *firmWare;
@property(assign, nonatomic) BOOL isRingAlgorithm; //是否使用设备的算法
@property(assign, nonatomic) ECG_CONCLUSION conclusion;  // 结论
@property(assign, nonatomic) ECG_WEAR_HAND wearHand;

/* 复制心电结果 */
@property(assign, nonatomic)CA_ECG_Arrhythmia arrhythmia; // 心率检查结果

@property(assign, nonatomic)CA_ECG_Signal_Quality ecgSq; // 信号质量

// 心电图信号振幅很低，请确保接触面清洁，然后重试。
@property(assign, nonatomic)BOOL low_amplitude;

//心电图信号有明显的噪音，请确保设备没有握得太紧，然后重试。
@property(assign, nonatomic)BOOL significant_noise;

//心电图信号似乎不稳定，请确保您保持静止，然后重试。
@property(assign, nonatomic)BOOL unstable_signal;

//没有足够的数据，请确保遵循心电图记录指南，然后重试。
@property(assign, nonatomic)BOOL not_enough_data;

@property(assign, nonatomic)NSInteger rmssd, sdnn;

@property(assign, nonatomic)NSInteger stress; // 压力指数 0-100有效 0XFF表示无效

@property(assign, nonatomic)NSInteger bmr; // basal metabolic rate, Unit: Cards per minute(基础代谢率, 单位：卡每分钟)

@property(assign, nonatomic)NSInteger activeCal; // Active energy consumption, Unit: Cards per minute(有功能量消耗, 单位：卡每分钟)
/* 复制心电结果 */
//@property(strong, nonatomic) NSMutableArray<NSNumber *> *symptomsArray; //自己添加的症状
@property(strong, nonatomic) NSMutableArray <NSNumber *> *volArray; // 电压值

//@property(assign, nonatomic) ECG_FREQ_TYPE frequencyType; // 标记 采集数据的频率是多少

- (instancetype)initWithAccount:(NSString * )account;

-(ECG_FREQ_TYPE)frequencyType;
-(int)frequencyValue;


-(void)setValuesWith:(CAEcgAlgorithmResults *) ecgRes;
-(void)updateSymptoms:(void(^)(BOOL succ))complete;
-(void)deleteFromTable:(void (^)(void))cmpBlk;

+(NSString *)descOfConclusion:(ECG_CONCLUSION)conclusion;
+(NSString *)titleOfConclusion:(ECG_CONCLUSION)conclusion;

-(NSMutableAttributedString *)symptomsPdfAttrstring;

-(void)analyFromNetArrhythmia:(NSDictionary *)dict;
-(void)acceptFilterArray:(NSArray *)netFilterWaves;


@end

NS_ASSUME_NONNULL_END
